<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>编辑会议纪要-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.wbai{ width:100%; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">会议纪要 > 编辑会议纪要</div>
	</div>
	<div id="content">
		<form action="__APP__/Index/meeting_minutes_edit" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="edit">
			<div class="form-main">
				<div class="form-title">编辑会议纪要</div>
				<div class="form-item clearfix">
					<div class="item-float">
						<div class="input-label">所属中心</div>
						<div class="input-item">
							{$result['center_name']}
						</div>
					</div>
					<div class="item-float">
						<div class="input-label">关联会议纪要</div>
						<div class="input-item">
							<if condition="$result['hy_id'] neq NULL">[{$result['hy_num']}]{$result['mb_name']}</if>
						</div>
					</div>
				</div>
				<div class="form-item clearfix">
					<div class="item-float">
						<div class="input-label">会议模板</div>
						<div class="input-item">
							{$result['module_name']}
						</div>
					</div>
					<div class="item-float">
						<div class="input-label">编号</div>
						<div class="input-item">
							{$result['meeting_num']}
						</div>
					</div>
				</div>
				<div class="form-item clearfix">
					<div class="item-float">
						<div class="input-label"><span class="asterisk">*</span>会议日期</div>
						<div class="input-item">
							<input name="date" type="text" class="form-control Wdate required-text w100" onclick="WdatePicker()" readonly="" autocomplete="off" value="{$result['date']}">
							<span class="error-item">必填项</span>
						</div>
					</div>
					<div class="item-float">
						<div class="input-label"><span class="asterisk">*</span>会议地点</div>
						<div class="input-item">
							<input type="text" name="meeting_address" class="form-control required-text" autocomplete="off" value="{$result['meeting_address']}">
							<span class="error-item">必填项</span>
						</div>
					</div>
				</div>
				<div class="pep_cont">
					<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>与会人员</div>
						<div class="input-item">
							<button type="button" class="is_all btn is_all_btn">选择用户</button>
							<span class="error-item">请选择用户</span>
							<div class="users-list"><if condition="$users neq NULL"><strong>已选用户：</strong>{$users}</if></div>
							<input type="hidden" name="uids" value="{$uids}" class="uids-input" autocomplete="off"/>
							<input type="hidden" name="users" value="{$users}" class="users-input" autocomplete="off"/>
						</div>
					</div>
					<if condition="($actio eq add) and ($nall eq NULL)">
						<div class="form-item hide">
							<div class="input-label"></div>
							<div class="input-item">
								<strong>备注缺席：</strong>
								<span class="nuser-cont"></span>
							</div>
						</div>
					<else/>
						<if condition="$nall neq NULL">
							<div class="form-item">
								<div class="input-label"></div>
								<div class="input-item">
									<strong>备注缺席：</strong>
									<span class="nuser-cont">
										<foreach name="nall" item="do">
											<if condition="$key neq 0"><span>，</span></if>
											<span class="mr10">{$do['username']}</span>
											<input type="hidden" name="i_uid[]" value="{$do['uid']}">
											<select name='d_uid[]' class='form-control w100 select' autocomplete='off'>
												<option value="-10" <if condition="$do['d_uid'] eq NULL">selected</if>>无</option>
												<foreach name="userss" item="so">
													<if condition="$do['uid'] neq $so['id']">
														<option value="{$so['id']}" <if condition="$do['d_uid'] eq $so['id']">selected</if>>{$so['username']}</option>
													</if>
												</foreach>
											</select>
										</foreach>
									</span>
								</div>
							</div>
						<else/>
							<div class="form-item hide">
								<div class="input-label"></div>
								<div class="input-item">
									<strong>备注缺席：</strong>
									<span class="nuser-cont"></span>
								</div>
							</div>
						</if>
					</if>
				</div>
			</div>
			<div class="form-main">
				<div class="form-title">会议呈报</div>
				<foreach name="detail" item="xo">
					<div class="form-item">
						<div class="form-name">
							<span class="name_btn" href="javascript:;">{$xo['username']}({$xo['department_name']})<if condition="$xo['d_username'] neq NULL">&nbsp;{$xo['d_username']}&nbsp;代</if><a class="arrow ml10" href="javascript:;"><i class="glyphicon glyphicon-chevron-right"></i></a></span>
						</div>
						<div class="toggle-item hide pt15 clearfix">
							<div class="mb10 left">
								<div class="input-label">事项</div>
								<div class="input-item">
									<textarea class="form-control comment-textarea wbai h150" autocomplete="off" name="matter" data-id="1">{$xo['matter']}</textarea>
								</div>
							</div>
							<if condition="$result['hy_id'] neq NULL">
							<div class="mb10 left gl_text">
								<div class="input-label">关联事项</div>
								<p>{$xo['matter_hy']}</p>
							</div>
							</if>
							<div class="mb10 left">
								<div class="input-label">批复意见</div>
								<div class="input-item">
									<textarea class="form-control comment-textarea wbai h150" autocomplete="off" name="reply" data-id="2">{$xo['reply']}</textarea>
								</div>
							</div>
							<if condition="$result['hy_id'] neq NULL">
							<div class="mb10 left gl_text">
								<div class="input-label">关联批复意见</div>
								<p>{$xo['reply_hy']}</p>
							</div>
							</if>
							<div class="mb10 left">
								<div class="input-label">待办</div>
								<div class="input-item">
									<textarea class="form-control comment-textarea wbai h150" autocomplete="off" name="ready_things" data-id="3">{$xo['ready_things']}</textarea>
								</div>
							</div>
							<if condition="$result['hy_id'] neq NULL">
							<div class="mb10 left gl_text">
								<div class="input-label">关联待办</div>
								<p>{$xo['ready_things_hy']}</p>
							</div>
							</if>
						</div>
						<input type="hidden" name="uid" value="{$xo['id']}">
					</div>
				</foreach>
			</div>
			<input type="hidden" name="mid" value="{$result['id']}">
			<div class="form-btn-item"><button class="btn submit" type="submit">提交</button><button class="btn btn-default goback js_back1" type="button">返回</button></div>
		</form>
	</div>
</div>
<!--选择用户-->
<div class="modal fade" id="selectuser-modal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>选择用户</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<foreach name="user_list" item="do">
					<div class="department">
						<label><input class="department-checkbox" type="checkbox" autocomplete="off" />{$do['name']}</label>
					</div>
					<ul>
						<foreach name="do['user']" item="uo">
							<li>
								<label><input class="user-checkbox" type="checkbox" value="{$uo['id']}" <if condition="$uo['cho'] eq 1">onclick="return false;"</if> autocomplete="off" />{$uo['username']}</label>
							</li>
						</foreach>
					</ul>
				</foreach>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn user-all">全选</button><button type="button" class="btn user-affirm">确认</button><button type="button" class="btn btn-default user-cancel" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript" src="__PUBLIC__/js/user_select.js"></script>
<script type="text/javascript">
$(function(){
	$(".js_back1").click(function(){
		var $actio = "{$actio}";
		if($actio=="add"){
			window.location.href = "__APP__/Index/meeting_minutes/center_id/{$center_id}/&p={$_SESSION['page']}";
		}else{
			window.location.href = document.referrer;
		}
	});
	$('.comment-textarea').each(function(){
		var textss = $(this).text(),
			reg2 = new RegExp("<br/>", "g"),
			str = textss.replace(reg2, "\n");
		$(this).html(str);
	})
	//全选
	$('body').on('click','.user-all',function(){
		$(this).addClass('user-active');
		$(this).html("取消全选");
		$('.modal-body').find('.user-checkbox').prop("checked",true);
	})
	$('body').on('click','.user-active',function(){
		$(this).removeClass('user-active');
		$(this).html("全选");
		$('.modal-body').find('.user-checkbox').removeAttr("checked");
	})
	//人员选择
	$(".is_all").click(function(){
		$("#selectuser-modal").modal("show");
	});
	$('.user-affirm').click(function(){
		var uids = "",
			mid_val = $("[name='mid']").val();
		$("#selectuser-modal").find(".user-checkbox").each(function(){
			if($(this).prop("checked")){
				uids += $(this).val()+",";
			}
		});
		uids = uids.replace(/\,$/,"");
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"uids":uids,"mid":mid_val,"action":"users"},
			url:"__APP__/Index/meeting_minutes_ajax",
			success:function(data){
				var html = '',
					nuser = $('.nuser-cont'),
					list = "<div class='form-title'>会议呈报</div>",
					hy = "{$result['hy_id']}";
				if(data.nall){
					$('.nuser-cont').parents('.form-item').removeClass('hide');
					for(var i=0;i<data.nall.length;i++){
						html+= "<span class='mr10'>"+data.nall[i].username+"</span>";
						html+= "<input type='hidden' name='i_uid[]' value='"+data.nall[i].id+"'>";
						html+= "<select name='d_uid[]' class='form-control w100 select' autocomplete='off'>";
						html+= "<option value='-10'>无</option>";
						for(var t=0;t<data.users.length;t++){
							if(data.nall[i].id!=data.users[t].id){
								html+= "<option value='"+data.users[t].id+"'>"+data.users[t].username+"</option>";
							}
						}
						html+= "</select>";
						if(i<data.nall.length-1){
							html+= "<span>，</span>";
						}
						$("[name='d_uid[]']").eq(i).val(data.nall[i].d_uid);
					}
				}else{
					$('.nuser-cont').parents('.form-item').addClass('hide');
				}
				nuser.html(html);
				nuser.find('select').select2();
				for(var s=0;s<data.detail.length;s++){
					list+= "<div class='form-item'>";
					list+= "<div class='form-name'><span class='name_btn' href='javascript:;'>"+data.detail[s].username+"("+data.detail[s].department_name+")&nbsp;"+data.detail[s].d_username+"";
					if(data.detail[s].d_username){
						list+= "&nbsp;代";
					}
					list+= "<a class='arrow ml10' href='javascript:;'><i class='glyphicon glyphicon-chevron-right'></i></a></span></div>";
					list+= "<div class='toggle-item hide pt15 clearfix'>";
					list+= "<div class='mb10 left'><div class='input-label'>事项</div><div class='input-item'><textarea class='form-control comment-textarea wbai h150' autocomplete='off' name='matter' data-id='1'>";
					if(data.detail[s].matter){
						list+= ""+data.detail[s].matter+"";
					}
					list+= "</textarea></div></div>";
					if(hy){
						list+= "<div class='mb10 left gl_text'><div class='input-label'>关联事项</div><p>";
						if(data.detail[s].matter_hy){
							list+= ""+data.detail[s].matter_hy+"";
						}
						list+= "</p></div>";
					}
					list+= "<div class='mb10 left'><div class='input-label'>批复意见</div><div class='input-item'><textarea class='form-control comment-textarea wbai h150' autocomplete='off' name='reply' data-id='2'>";
					if(data.detail[s].reply){
						list+= ""+data.detail[s].reply+"";
					}
					list+= "</textarea></div></div>";
					if(hy){
						list+= "<div class='mb10 left gl_text'><div class='input-label'>关联批复意见</div><p>";
						if(data.detail[s].reply_hy){
							list+= ""+data.detail[s].reply_hy+"";
						}
						list+= "</p></div>";
					}
					list+= "<div class='mb10 left'><div class='input-label'>待办</div><div class='input-item'><textarea class='form-control comment-textarea wbai h150' autocomplete='off' name='ready_things' data-id='3'>";
					if(data.detail[s].ready_things){
						list+= ""+data.detail[s].ready_things+"";
					}
					list+= "</textarea></div></div>";
					if(hy){
						list+= "<div class='mb10 left gl_text'><div class='input-label'>关联待办</div><p>";
						if(data.detail[s].ready_things_hy){
							list+= ""+data.detail[s].ready_things_hy+"";
						}
						list+= "</p></div>";
					}
					list+= "</div>";
					list+= "<input type='hidden' name='uid' value='"+data.detail[s].id+"'>";
					list+= "</div>"
				}
				$('.form-main').eq(1).html(list);
			}
		});
	})
	$('body').on("blur",".comment-textarea",function(){

		var dataid = $(this).attr('data-id'),
			val = $(this).val();
			reg = new RegExp("\n", "g"),
    		str = val.replace(reg, "<br/>"),
			id = $(this).parents('.form-item').find("[name='uid']").val();
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"dataid":dataid,"id":id,"val":str,"action":"message"},
			url:"__APP__/Index/meeting_minutes_ajax",
			success:function(data){

			}
		});
	})
	$('body').on("change","[name='d_uid[]']",function(){
		var inpval = $(this).prev('input').val(),
			val = $(this).val();
			mid = $("[name='mid']").val(),
			hy = "{$result['hy_id']}";
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"uid":inpval,"d_uid":val,"mid":mid,"action":"user_add"},
			url:"__APP__/Index/meeting_minutes_ajax",
			success:function(data){
				var list = "<div class='form-title'>会议呈报</div>";
				for(var s=0;s<data.detail.length;s++){
					list+= "<div class='form-item'>";
					list+= "<div class='form-name'><span class='name_btn' href='javascript:;'>"+data.detail[s].username+"("+data.detail[s].department_name+")&nbsp;"+data.detail[s].d_username+"";
					if(data.detail[s].d_username){
						list+= "&nbsp;代";
					}
					list+= "<a class='arrow ml10' href='javascript:;'><i class='glyphicon glyphicon-chevron-right'></i></a></span></div>";
					list+= "<div class='toggle-item hide pt15 clearfix'>";
					list+= "<div class='mb10 left'><div class='input-label'>事项</div><div class='input-item'><textarea class='form-control comment-textarea wbai h150' autocomplete='off' name='matter' data-id='1'>";
					if(data.detail[s].matter){
						list+= ""+data.detail[s].matter+"";
					}
					list+= "</textarea></div></div>";
					if(hy){
						list+= "<div class='mb10 left gl_text'><div class='input-label'>关联事项</div><p>";
						if(data.detail[s].matter_hy){
							list+= ""+data.detail[s].matter_hy+"";
						}
						list+= "</p></div>";
					}
					list+= "<div class='mb10 left'><div class='input-label'>批复意见</div><div class='input-item'><textarea class='form-control comment-textarea wbai h150' autocomplete='off' name='reply' data-id='2'>";
					if(data.detail[s].reply){
						list+= ""+data.detail[s].reply+"";
					}
					list+= "</textarea></div></div>";
					if(hy){
						list+= "<div class='mb10 left gl_text'><div class='input-label'>关联批复意见</div><p>";
						if(data.detail[s].reply_hy){
							list+= ""+data.detail[s].reply_hy+"";
						}
						list+= "</p></div>";
					}
					list+= "<div class='mb10 left'><div class='input-label'>待办</div><div class='input-item'><textarea class='form-control comment-textarea wbai h150' autocomplete='off' name='ready_things' data-id='3'>";
					if(data.detail[s].ready_things){
						list+= ""+data.detail[s].ready_things+"";
					}
					list+= "</textarea></div></div>";
					if(hy){
						list+= "<div class='mb10 left gl_text'><div class='input-label'>关联待办</div><p>";
						if(data.detail[s].ready_things_hy){
							list+= ""+data.detail[s].ready_things_hy+"";
						}
						list+= "</p></div>";
					}
					list+= "</div>";
					list+= "<input type='hidden' name='uid' value='"+data.detail[s].id+"'>";
					list+= "</div>"
				}
				$('.form-main').eq(1).html(list);
			}
		});
	})
	//呈报展开
	$('body').on('click','.name_btn',function(){
		var _this = $(this),
			icon = _this.find('.arrow i');
		if(icon.hasClass('glyphicon-chevron-right')){
			_this.parents('.form-item').addClass('active').siblings('.form-item').removeClass('active');
			_this.parent().siblings('.toggle-item').slideDown();
			icon.removeClass('glyphicon-chevron-right').addClass('glyphicon-chevron-up');
			_this.parents('.form-item').siblings('.form-item').find('.toggle-item').slideUp();
			_this.parents('.form-item').siblings('.form-item').find('i').removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-right');
		}else{
			_this.parents('.form-item').removeClass('active');
			_this.parent().siblings('.toggle-item').slideUp();
			icon.removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-right');
		}
	})
	//隐藏错误提示
	$(document).on("focus",".required-text",function(){
		$(this).nextAll(".error-item").hide();
	});
	$(document).on("change",".select-add",function(){
		$(this).nextAll(".error-item").hide();
	});
	$(".is_all_btn").click(function(){
		$(this).siblings(".error-item").hide();
	});
});
</script>
</body>
</html>